'use strict';

const Controller = require('../core/base_controller');

class HomeController extends Controller {
  async index() {
    const {ctx,app} = this;
    let query = ctx.query;
    let openid = query.openid;

    const config = this.ctx.app.config;
    let view = "";
    if (config.isdev){
      view = '/index_test.tpl'
    }else{
      view = '/index.tpl'
    }

    await this.ctx.render(view, {
      title: '佳悦洗',
      openid:openid,
      cdnHost: config.cdnHost,
    });
  }

  async test() {
    const app = this.ctx.app;
    const id = this.ctx.query.id;

    const WorkTimePack = app.iot.packs[4];

    this.ctx.body = await app.iot.send(id, WorkTimePack.req(0));
  }
}

module.exports = HomeController;
